const fs = require("fs");

const str = "asdfghjkl";
const arr = ["male",'flmale'];

const num = process.argv[2];
const data = [];
function student(){
  const name = str[Math.floor(Math.random()*str.length)];
  const age = Math.ceil((Math.random()*7)+18);
  const sex = arr[Math.round(Math.random())];
  return {name:name,age:age,sex:sex}
}


for(let i=0;i<num;i++){
  data.push(student());
}

// console.log(data);
// const fileName = process.argv[3] || 'data.json';
fs.writeFile('student.json', JSON.stringify(data), err => {
  console.log('err', err);
});
